package test

import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.TableName
import org.apache.hadoop.hbase.client.HTable
import org.apache.hadoop.hbase.client.Put
import org.apache.hadoop.hbase.util.Bytes

object htest {
  def main(args: Array[String]): Unit = {
     //Hbase配置
      val tableName = "t1"
      val hbaseConf = HBaseConfiguration.create()

      //用户ID
      val uid = "zzz333"
      //点击次数
      val click = "1000"
      //组装数据
      val put = new Put(Bytes.toBytes(uid))
      //put.add("f1".getBytes, "age".getBytes, Bytes.toBytes(click))

      val explicitTimeInMs = 559;  // just an example
       put.add(Bytes.toBytes("f1"), Bytes.toBytes("age"), explicitTimeInMs, Bytes.toBytes(click))
      
      val StatTable = new HTable(hbaseConf, TableName.valueOf(tableName))
      StatTable.setAutoFlush(false, false)
      //写入数据缓存
      StatTable.setWriteBufferSize(3 * 1024 * 1024)
      StatTable.put(put)
      //提交
      StatTable.flushCommits()
  }
}